package com.smarthealthring.mm.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.TextView;

import com.smarthealthring.mm.R;
import com.smarthealthring.mm.base.BaseActivity;
import com.smarthealthring.mm.base.IPresenter;
import com.smarthealthring.mm.utils.SPUtils;
import com.jakewharton.rxbinding2.view.RxView;

import butterknife.BindView;
import io.reactivex.functions.Consumer;

public class SplashActivity extends BaseActivity {
    @BindView(R.id.tv_next)
    TextView mTvNext;

    @Override
    protected void initComToolBar() {

    }

    @Override
    protected int getLayout() {
        return R.layout.act_splash;
    }

    @Override
    protected void initEventAndData(@Nullable Bundle savedInstanceState) {
//        RxView.clicks(mTvNext)
//                .subscribe(new Consumer<Object>() {
//                    @Override
//                    public void accept(Object o) throws Exception {
//                        String userName = SPUtils.getString(SPUtils.USERNAME, "");
//
//                        if(!TextUtils.isEmpty(userName)){
//                            startActivity(new Intent(mContext,HomeActivity.class));
//                        } else {
//                            startActivity(new Intent(mContext,LoginActivity.class));
//                        }
//                        sport_finish();
//                    }
//                });

        String userName = SPUtils.getString(SPUtils.USERNAME, "");

        if(!TextUtils.isEmpty(userName)){
            startActivity(new Intent(mContext,HomeActivity.class));
        } else {
            startActivity(new Intent(mContext,LoginActivity.class));
        }
        finish();
    }

    @Override
    protected IPresenter createPresenter() {
        return null;
    }
}
